<?php

/**
 * Release form base class.
 *
 * @method Release getObject() Returns the current form's model object
 *
 * @package    packagesdispenser
 * @subpackage form
 * @author     Nicolas Surian aka NairuS <contact@nairus.fr>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseReleaseForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'project_id' => new sfWidgetFormInputHidden(),
      'version'    => new sfWidgetFormInputHidden(),
      'fail'       => new sfWidgetFormTextarea(),
      'mode'       => new sfWidgetFormChoice(array('choices' => array('auto' => 'auto', 'manual' => 'manual'))),
      'status'     => new sfWidgetFormChoice(array('choices' => array('building' => 'building', 'completed' => 'completed', 'failed' => 'failed'))),
      'created_at' => new sfWidgetFormDateTime(),
      'updated_at' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'project_id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('project_id')), 'empty_value' => $this->getObject()->get('project_id'), 'required' => false)),
      'version'    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('version')), 'empty_value' => $this->getObject()->get('version'), 'required' => false)),
      'fail'       => new sfValidatorString(array('required' => false)),
      'mode'       => new sfValidatorChoice(array('choices' => array(0 => 'auto', 1 => 'manual'), 'required' => false)),
      'status'     => new sfValidatorChoice(array('choices' => array(0 => 'building', 1 => 'completed', 2 => 'failed'), 'required' => false)),
      'created_at' => new sfValidatorDateTime(),
      'updated_at' => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('release[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Release';
  }

}
